import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ApiService } from 'src/app/core/api';
import { Global } from 'src/app/core/global';
import { StorageService } from 'src/app/core/sotrage/storage.service';

@Component({
	templateUrl: './index.component.html',
	styleUrls: ['./index.component.less'],
})
export class GzComponent implements OnInit {
	type=0;
	orderList=[];
	gList=[];
	pageNo = 1;
	constructor( private router: Router, private global: Global, private api: ApiService, private sto: StorageService, private activedRoute: ActivatedRoute) {
		this.type = this.activedRoute.snapshot.queryParams.type || 0;
	}

	ngOnInit() {
		this.api.post('用户关注旅行社列表', { pageNo: this.pageNo }).then(res => {
			res['data'].list.forEach(e => {
				e['image'] = e['images'].split(",")[0];
			});
			this.orderList = this.orderList.concat(res['data']['list']);
		});
		this.api.post('用户关注导游列表', { pageNo: this.pageNo }).then(res => {
			res['data'].list.forEach(e => {
				e['image'] = e['images'].split(",")[0];
			});
			this.gList = this.gList.concat(res['data']['list']);
		});
	}

	changeTab(num) {
		this.type=num;
	}
	goPay(e,type) {
		switch (type) {
			case 'A':
				this.router.navigate(['/order'], {
					queryParams: {
						travelAgencyId: e.agencyId,
						reservationFee: e.reservationFee,
						isLXS: 'gzAgency',
					},
				});
				break;
			case 'G':
					this.router.navigate(['/order'], {
						queryParams: {
							travelGuideId: e.guideId,
							reservationFee: e.reservationFee,
							isLXS: 'false',
							type:'1'
						},
					});
				break;
		}
	}
	
	goDel(e,type) {
		switch (type) {
			case 'A':
					this.router.navigate(['/agency'], {
						queryParams: {
							travelAgencyId: e.agencyId,
						},
					});
				break;
			case 'G':
					this.router.navigate(['/guide'], {
						queryParams: {
							travelGuideId: e.guideId,
							type: '1',
						},
					});
				break;
		}
	}
}

